package com.digitalchina.lxnsy.api;

import android.app.Activity;
import android.os.Handler;

import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.digitalchina.lxnsy.xml.UserXML;
import com.lzy.okhttputils.model.HttpParams;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.api
 * 创建人：白彦东
 * 创建时间：2016/10/20 10:12
 * 修改备注：
 * ================================================
 */

public class BusinessTechnology {

    /**
     * 热门答案列表(农技智库列表)
     *
     * @param activity
     * @param condition 查询关键字
     * @param handler
     */
    public static void getTechnologyList(Activity activity, String condition, String offset, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("condition", condition);
        params.put("offset", offset);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_TECHNOLOGY_LIST, "", params, handler,
                MSG.MSG_TECHNOLOGY_LIST_SUCCESS, MSG.MSG_TECHNOLOGY_LIST_SUCCESS);

    }


    /**
     * 农技智库热门答案列表-自动匹配
     *
     * @param activity
     * @param query
     * @param limit
     * @param handler
     */
    public static void questionAuto(Activity activity, String query, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("query", query);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_QUESTION_AUTO, "", params, handler,
                MSG.MSG_QUESTION_AUTO_SUCCESS, MSG.MSG_QUESTION_AUTO_FIELD);

    }

    /**
     * 我的提问列表
     *
     * @param activity
     * @param count    总数
     * @param handler
     */
    public static void showMyQuestionList(Activity activity, String count, String offset, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("count", count);
        params.put("offset", offset);
        params.put("limit", limit);
        params.put("id", UserXML.getId(activity));

        OkHttpUtil.post(activity, URL.URL_SHOW_MY_QUESTION_LIST, "", params, handler,
                MSG.MSG_SHOW_MY_QUESTION_LIST_SUCCESS, MSG.MSG_SHOW_MY_QUESTION_LIST_FIELD);

    }

    /**
     * 我的回答列表
     *
     * @param activity
     * @param count      总数
     * @param questionId 问题id，为空查全部
     * @param answerId   答案id， 为空查全部
     * @param handler
     */
    public static void showMyAnswerList(Activity activity, String count, String questionId, String answerId, String offset, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("count", count);
        params.put("questionId", questionId);
        params.put("answerId", answerId);
        params.put("offset", offset);
        params.put("limit", limit);
        params.put("id", UserXML.getId(activity));

        OkHttpUtil.post(activity, URL.URL_SHOW_MY_ANSWER_LIST, "", params, handler,
                MSG.MSG_SHOW_MY_ANSWER_LIST_SUCCESS, MSG.MSG_SHOW_MY_ANSWER_LIST_FIELD);

    }

    /**
     * 获取分享问题答案内容
     *
     * @param activity
     * @param answerId 问题答案ID
     * @param handler
     */
    public static void fetchAnswerShareData(Activity activity, String answerId, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("answerId", answerId);

        OkHttpUtil.post(activity, URL.URL_FETCH_ANSWER_SHARE_DATA, "", params, handler,
                MSG.MSG_FETCH_ANSWER_SHARE_DATA_SUCCESS, MSG.MSG_FETCH_ANSWER_SHARE_DATA_FIELD);

    }

    /**
     * 获取回答问题列表
     *
     * @param activity
     * @param offset   页
     * @param limit    条数
     * @param handler
     */
    public static void showNewQuestions(Activity activity, String offset, String limit, String count, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("limit", limit);
        params.put("offset", offset);
        params.put("count", count);

        OkHttpUtil.post(activity, URL.URL_SHOW_NEW_QUESTIONS, "", params, handler,
                MSG.MSG_SHOW_NEW_QUESTIONS_SUCCESS, MSG.MSG_SHOW_NEW_QUESTIONS_FIELD);

    }

}
